using System;
using System.Collections.Generic;
using System.Text;

namespace Barbar.MapReport.DataSource.Esri {
  /// <summary>
  /// Represent point in Shp file
  /// </summary>
  public struct ShpPoint {
    /// <summary>
    /// X coordinate
    /// </summary>
    [System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Design", "CA1051:DoNotDeclareVisibleInstanceFields")]
    [System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Naming", "CA1704:IdentifiersShouldBeSpelledCorrectly", MessageId = "X")]
    public double X;
    /// <summary>
    /// Y coordinate
    /// </summary>
    [System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Naming", "CA1704:IdentifiersShouldBeSpelledCorrectly", MessageId = "Y")]
    [System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Design", "CA1051:DoNotDeclareVisibleInstanceFields")]
    public double Y;

    public override bool Equals(object obj) {
      ShpPoint point = (ShpPoint)obj;
      return X == point.X && Y == point.Y;
    }

    public override int GetHashCode() {
      return X.GetHashCode() ^ Y.GetHashCode();
    }

    private static bool Compare(ShpPoint pointA, ShpPoint pointB) {
      return pointA.X == pointB.X && pointA.Y == pointB.Y;
    }

    public static bool operator==(ShpPoint pointA, ShpPoint pointB) {
      return Compare(pointA, pointB);
    }

    public static bool operator !=(ShpPoint pointA, ShpPoint pointB) {
      return !Compare(pointA, pointB);
    }
  }
}
